/**
 * Created by wei on 16-8-31.
 * 选择图片
 */
angular.module("task.commonChoicePhotoController", ["starter.taskService", "starter.taskDirective"])
  .controller("CommonChoicePhotoCtrl", function ($scope, $design, $stateParams, $log, $dfBoradcast, $ionicHistory, $timeout) {
    var properties = $stateParams.args.properties;
    $scope.code = $stateParams.args.code;

    $scope.items = $design.getWithProperty(properties);

    $timeout(function () {
      var choicePhotoItems = document.getElementsByClassName("choicePhotoItem");

      if (typeof choicePhotoItems[0] == "object"){
        $scope.choicePhotoItemHeight = {"height": choicePhotoItems[0].offsetWidth+40+"px"};
      }
    },10);

    $scope.choose = function (item) {
      $dfBoradcast.sendBoradcastOnce('designSelected', item);
      $scope.finish();
    }
    $scope.finish = function () {
      $ionicHistory.goBack();
    }
  })

